package com.homework.test1029;

import java.util.Scanner;

public class Item {
    private Book book;
    private int quantity;

    public Book getBook() {
        return book;
    }

    public void setBook(Book book) {
        this.book = book;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public Book whichBook(Book[] book){
        Scanner input = new Scanner(System.in);
        System.out.println("请输入图书编号:");
        int bookID = input.nextInt();
        if (bookID == book[0].getId()){
            return book[0];
        }else if (bookID == book[1].getId()){
            return book[1];
        }else if (bookID == book[2].getId()){
            return book[2];
        }
        return null;
    }

    public int howMany(){
        Scanner input = new Scanner(System.in);
        System.out.println("请输入购买数量:");
        int bookQuant = input.nextInt();
        this.setQuantity(bookQuant);
        System.out.println("请继续购买图书");
        return this.getQuantity();
    }
}
